﻿

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>用户管理</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<script type ="text/javascript">


	Ext.onReady(function()
	{
		//Ext.namespace("com.group1");
		var grid ;
		var win_update ;
		var win_add;
		var store;

		
		var ht = Ext.get("main_tree").getHeight() -25;
		var addImg = getAddImg();
		var updateImg =getUpdateImg();
		var delImg =getDelImg();
		
		var txt_fbegttime= new Ext.form.DateField({
						name: "f_begtime"							
						}); 
						
		var txt_fendtime= new Ext.form.DateField({
						name: "f_endtime"						
						}); 
						
		var toolBar1 = new Ext.Toolbar(
				{
					items:
					[
						'开始日期',txt_fbegttime,
						'结束日期',txt_fendtime,
						{
							xtype:'tbbutton',
							text:'导出EXCEL',
							icon:addImg,cls:"x-btn-text-icon" , 
							cls: "x-btn-text-icon",
							handler: function()
							{ 
								var pstarttime;
								var pendtime;

								pstarttime = txt_fbegttime.getValue().dateFormat('Y-m-d').toString();
								pendtime = txt_fendtime.getValue().dateFormat('Y-m-d').toString();
							
								if(pstarttime.localeCompare(pendtime)>=0)
								{
									Ext.Msg.alert("导出EXCEL","开始时间必须小于结束时间");
									
								}else
								{
									window.location.href ='Json/CurrDataAction!export?'
										+"&p_starttime="+pstarttime
										+"&p_endtime="+pendtime;	
								}

							}
						}
					]
				});
		
		var sm = new Ext.grid.CheckboxSelectionModel();
		
		var cm = new Ext.grid.ColumnModel(
		[
			
			new Ext.grid.RowNumberer(),
			sm,
			{header: "编号", width: 50, dataIndex: "id"},
			{header: "现场程序编号", width: 120, dataIndex: "app_id"},
			{header: "串口号", width: 70, dataIndex: "com_id"},
			{header: "串口地址", width: 70, dataIndex: "com_addr"},
			{header: "通道0", width: 70, dataIndex: "chn0"},
			{header: "通道1", width: 70, dataIndex: "chn1"},
			{header: "通道2", width: 70, dataIndex: "chn2"},
			{header: "通道3", width: 70, dataIndex: "chn3"},
			{header: "通道4", width: 70, dataIndex: "chn4"},
			{header: "通道5", width: 70, dataIndex: "chn5"},
			{header: "通道6", width: 70, dataIndex: "chn6"},
			{header: "通道7", width: 70, dataIndex: "chn7"},
			{id: "createtime",header: "创建时间", width: 100, dataIndex: "createtime" }
		]);

		
		
		var proxy = new Ext.data.HttpProxy({url: "Json/CurrDataAction!list"});
		//Record	定义记录结果
		var Manager = Ext.data.Record.create([
			{name: "id", type: "string", mapping: "id"},
			{name: "app_id", type: "string", mapping: "app_id"},
			{name: "com_id", type: "string", mapping: "com_id"},
			{name: "com_addr", type: "string", mapping: "com_addr"},
			{name: "chn0", type: "string", mapping: "chn0"},
			{name: "chn1", type: "string", mapping: "chn1"},
			{name: "chn2", type: "string", mapping: "chn2"},
			{name: "chn3", type: "string", mapping: "chn3"},
			{name: "chn4", type: "string", mapping: "chn4"},
			{name: "chn5", type: "string", mapping: "chn5"},
			{name: "chn6", type: "string", mapping: "chn6"},
			{name: "chn7", type: "string", mapping: "chn7"},
			{name: "createtime", type: "string", mapping: "createtime"}
		]);
		
		
		var reader = new Ext.data.JsonReader(
		{totalProperty: "totalProperty", root: "root"},   
		Manager 
		);

		//Store
		store = new Ext.data.Store
		({
		proxy: proxy,
		reader: reader
		});
		//store.load();
		store.load({params: {start: 0, limit: 10}});

		grid = new Ext.grid.GridPanel({
			region:'center',
			//title: "中国公民",
			width:600,
   			height:300,
			cm: cm,
			sm: sm,
			store: store,
			//renderTo: "group1_managelist",
			autoExpandColumn: "createtime", //自动伸展，占满剩余区域
			tbar:toolBar1,
			bbar: new Ext.PagingToolbar({
					store: store, //这个不用介绍了吧？
					pageSize: 10,//页大小
					displayInfo: true,//是否显示 displayMsg
					displayMsg: "本页显示第{0}条到第{1}条的记录,一共{2}条",
					emptyMsg: "没有记录"//如果没有记录，则显示该文本
				}),
			listeners:
			{

			}
			
		});	
		
		grid.getStore().on("remove", function(s, record, index)
		{		
			var jsonArray = [record.data];
			Ext.Ajax.request({
			method: "post",
			url: "Json/CurrDataAction!delete",
			params: {f_data: Ext.util.JSON.encode(jsonArray)},
			success:function(response,opts) 
			{
			
				var jsonObj=Ext.util.JSON.decode(response.responseText );
				if(jsonObj.success==true)
				{
					store.reload();
					Ext.Msg.alert("成功", "删除成功!");
					
				}
				else
				{
					store.reload();
					Ext.Msg.alert("删除失败",jsonObj.msg);
					
				}
				
			}
			
			});
		});  

		
		
		var panel1 = new Ext.Panel({
		 //layout:'border',
		 layout:'fit',//自适应
  		items: [grid],
		//title:"最简单的面板11111111",
		//width:600,
		height:ht,
		titleCollapse:true,
		collapsible:false,
		renderTo:"curr_data_list"
		});
		
	});	
	
			
	</script>
  </head>
  
  <body>
     <div id="curr_data_list"></div>
  </body>
</html>
